/**
 * thread模块请求封装
 */
import { FORUM_RESULT, THREAD_ADD, FORUM_INITIALIZE } from '../mutation-types'
import { THREAD_AUD_URL } from '../../common/js/url'

const state = {
  threadReplyResult: false
}

// getters
const getters = {
  [FORUM_RESULT]: state => state.threadReplyResult
}

// mutations
const mutations = {
  [FORUM_INITIALIZE] () {
    this.threadReplyResult = false
  },
  [THREAD_ADD] (state, param) {
    this.$http.put(THREAD_AUD_URL, param).then(response => {
      console.log(response)
      state.threadReplyResult = response.data
    })
  }
}

// actions
const actions = {
  [FORUM_INITIALIZE] ({commit}) {
    commit(FORUM_INITIALIZE)
  },
  [THREAD_ADD]  ({commit}, param) {
    commit(THREAD_ADD, param)
  }
}

export default {
  state,
  getters,
  mutations,
  actions
}
